mui.init();
mui.plusReady(function() {
	//	window.addEventListener('refreshdom', function(event) {
	//		console.log(event.detail.val);
	//		userindex.reqcode(event.detail.val);
	//	})
	var userindex = new Vue({
		el: "#app",
		data: {
			data: {},
			tjdata: [],
			cxdata: [],
			newsdata: [],
			ggdata: [],
			postData:{
				p:1,
				size:10
			},
			goodslist:[],
			selectTitle: ''

		},
		mounted: function() {
			var _this = this;

			_this.$nextTick(function() {
				_this.cartView();
			});

		},
		methods: {
			cartView: function() {
				var _this = this;
				app.postUrl(apiurl + 'Mall/index.html', {}, function(res) {
					
					if(res.status === 1) {
						_this.tjdata = res.data.tj;
						_this.cxdata = res.data.cx;
						_this.ggdata = res.data.gg;
						_this.newsdata = res.data.news;

						setTimeout(function() {
							var swiper = new Swiper('.swiper-container', {
								pagination: {
									el: '.swiper-pagination',
								},
								autoplay: true,
							},200);
						})
					}
				});
				app.postUrl(apiurl + 'Mall/goodslist.html', _this.postData, function(res) {
					//console.log('1212'+JSON.stringify(res))
					if(res.status === 1){
						_this.goodslist = res.data;
					}
					
				})

			},
			refresh: function(done) {
				done();
			},
			infinite: function(done) {
				var _this = this;
				setTimeout(function() {
					_this.postData.p++;
					//console.log(JSON.stringify(_this.postData))
					app.postUrl(apiurl + 'Mall/goodslist.html', _this.postData, function(res) {
						console.log(JSON.stringify(res))
						if(res.status === 1) {
							//_this.data = res.data;
							if(res.data.length < 1) {
								setTimeout(function() {
									done(true)
								}, 1000)
								return;
							}
							res.data.forEach(function(value, index) {
								_this.goodslist.push(value);
							});
							setTimeout(function() {
								done()
							})
							//console.log(JSON.stringify(_this.data))
						}
					});

				}, 800);
			},
			openwin: function(gid) {
				mui.openWindow({
					url: 'view.html',
					id: 'view',
					extras: {
						name: 'mui',
						nid: gid,
					}
				});
			},
			openurl: function(urls,uid) {
				mui.openWindow({
					url: urls,
					id: uid,
					extras: {
						name: 'mui',
					}
				});
			},
			opentype: function(gid) {
				mui.openWindow({
					url: 'shoplist.html',
					id: 'shoplist',
					extras: {
						name: 'mui',
						nid: gid
					}
				});
			},
			openselect: function() {
				var _this = this;
				if(_this.selectTitle == ''){
					mui.toast(lang('搜索关健词不能为空'));
					return;
				}
				mui.openWindow({
					url: 'selectlist.html',
					id: 'selectlist',
					extras: {
						name: 'mui',
						nid: _this.selectTitle
					}
				});
			}


		}

	});

});